package com.flitsneak.designpatterns.creationalpatterns.factory.factorymethod.breakfastshop;

import com.flitsneak.designpatterns.creationalpatterns.factory.factorymethod.AbstractBreakfastShop;
import com.flitsneak.designpatterns.creationalpatterns.factory.factorymethod.Breakfast;

/**
 * Author: flitsneak
 * Date: 2022/6/1 9:02
 * Description:
 */
public class AmericanBreakfastShop extends AbstractBreakfastShop {
    @Override
    public <T extends Breakfast> T makeBreakfast(Class<T> clazz) {
        Breakfast americanBreakfast = null;

        try {
            americanBreakfast = (T) Class.forName(clazz.getName()).getDeclaredConstructor().newInstance();
        } catch (Exception e) {
            System.out.println("没有此配方！");
        }

        return (T) americanBreakfast;
    }
}
